﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MaxStudio.Concrete.DBUtility;
using MaxStudio.Concrete.Server.Dao;
using MaxStudio.Concrete.Server.Interface; 

namespace MaxStudio.Concrete.Server.Service
{
    public class FunctionesService : ServiceHandle , IFunctiones
    {
        public FunctionesService()
        {
 
        } 

        #region IFunctiones Members

        public OperationResult<tb_FunctionItem> getFunctionItemByID(int ID)
        {
            return getFunctionItemByID(getDateContext(), ID);
        }

        public OperationResult<tb_FunctionItem> getFunctionItemByID(ConcreteDaoDataContext dataContext, int ID)
        {
            OperationResult<tb_FunctionItem> result = new OperationResult<tb_FunctionItem>();
            tb_FunctionItem functionItem;
            try
            {
                functionItem = dataContext.getFunctionItemsByID(ID);
                if (functionItem == null)
                {
                    result.errorMessageKey = "Error";
                }
                else
                {
                    result.obj = functionItem;
                    result.operationSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);

            }
            return result;
        }

        public OperationResult<List<tb_FunctionItem>> getAllFunctionList(ConcreteDaoDataContext dataContext)
        {
            OperationResult<List<tb_FunctionItem>> result = new OperationResult<List<tb_FunctionItem>>();
            List<tb_FunctionItem> list = new List<tb_FunctionItem>();
            try
            {
                list = dataContext.getAllFuntionItems();
                if (list == null)
                {
                    result.errorMessageKey = "Error";
                }
                else
                {
                    result.obj = list;
                    result.operationSuccess = true;
                }
            }
            catch (Exception ex)
            {
                result.exceptionString = DlHelper.ExceptionString(ex);

            }
            return result;
        }

        public OperationResult<List<tb_FunctionItem>> getAllFunctionList()
        {
            return getAllFunctionList(getDateContext());
        }

        #endregion
    }
}
